package com.hanwin.settlement.domain;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

/**
 * 通用功能测试类
 * @author Damon S.
 * @version v1.0.1
 * @date 2019年12月05日 10:58
 */
public class CommonFunctionTester {

    @Test
    void testReturnStreamForEach() {
        Arrays.asList(1, 2, 3, 4, 5, 6).forEach(num -> {
            if (3 == num % 4) {
                return;
            }
            System.out.print(num + ", ");
        });
    }

    @Test
    void testBinaryFormat() {
        int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4, i7 = 7, i8 = 8, i16 = 16, i32 = 32;
        System.out.println("1 --> " + Integer.toBinaryString(i1));
        System.out.println("2 --> " + Integer.toBinaryString(i2));
        System.out.println("4 --> " + Integer.toBinaryString(i4));
        System.out.println("8 --> " + Integer.toBinaryString(i8));
        System.out.println("16 --> " + Integer.toBinaryString(i16));
        System.out.println("32 --> " + Integer.toBinaryString(i32));

        System.out.println("0&i1 --> " + Integer.toBinaryString(i0 & i1));
        System.out.println("1&i2 --> " + Integer.toBinaryString(i1 & i2));
        System.out.println("16&i2 --> " + Integer.toBinaryString(i16 & i2));

        System.out.println("1|i2 --> " + Integer.toBinaryString(i1 | i2));
        System.out.println("7&i2 --> " + Integer.toBinaryString(i7 & i2));
        System.out.println("7&i4 --> " + Integer.toBinaryString(i7 & i4));
        System.out.println("7&i8 --> " + Integer.toBinaryString(i7 & i8));
    }
}
